﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Transactions {
    import Engine.Managers.*;
    import Classes.*;
    import Modules.realtime.*;

    public class THarvest extends TWorldState {

        protected var m_resource:HarvestableResource;
        protected var m_coinYield:int;
        protected var m_newResPop:int;
        protected var m_newWorldPop:int;

        public function THarvest(_arg1:HarvestableResource){
            this.m_resource = _arg1;
            this.m_coinYield = _arg1.getCoinYield();
            this.m_newResPop = _arg1.getPopulationYield();
            this.m_newWorldPop = Global.world.citySim.getPopulation();
            super(_arg1);
        }
        override public function perform():void{
            signedWorldAction("harvest");
        }
        override protected function onWorldActionComplete(_arg1:Object):void{
            var _local2:int = _arg1.retCoinYield;
            if (this.m_coinYield != _local2){
                ErrorManager.addError(((((("Coin yield didn't match on harvest for " + this.m_resource.getItem().name) + ", expected ") + this.m_coinYield) + ", received ") + _local2), ErrorManager.ERROR_REMOTEOBJECT_FAULT);
            };
            this.m_resource.onHarvestComplete(_arg1);
            if (Config.DEBUG_MODE){
                if (this.m_newResPop != _arg1.objectPopulation){
                    ErrorManager.addError(((((("Error Baby Doobers: New population did not match for " + this.m_resource.getItem().name) + ", expected ") + this.m_newResPop) + ", received ") + _arg1.objectPopulation), ErrorManager.ERROR_REMOTEOBJECT_FAULT);
                } else {
                    if (this.m_newWorldPop != _arg1.worldPopulation){
                        ErrorManager.addError(((((("Error Baby Doobers: New world population did not match for " + this.m_resource.getItem().name) + ", expected ") + this.m_newWorldPop) + ", received ") + _arg1.worldPopulation), ErrorManager.ERROR_REMOTEOBJECT_FAULT);
                    };
                };
            };
        }
        override public function getRealtimeMethod():RealtimeMethod{
            return (new RealtimeMethod("showAction", "harvested", this.m_resource.getHarvestingDefinition().name));
        }

    }
}//package Transactions 
